<!--
 * @Author: zhangjingyu
 * @Date: 2021-03-17 14:42:22
 * @LastEditors: qinglong
 * @LastEditTime: 2021-05-18 15:36:29
 * @FilePath: \systemCenter\src\views\ftpManage\pricingTrial\pricingTest\pricingTest.vue
 * @Description: 模拟试算页面
-->
<template>
  <!-- 模拟试算页面 -->
  <div>
    <el-row class="container">
      <!-- 操作区域 -->
      <upper-template
        @search="(searchForm.page = 1), searchFunc()"
        @clear="clearSearch"
        importIcon
        exportIcon
        :configIcon="false"
      >
        <!-- 操作按钮区 -->
        <template slot="buttonArea">
          <el-button @click="addFunc()">新增</el-button>
          <el-button @click="editFunc()">编辑</el-button>
          <el-button @click="copyFunc()">复制</el-button>
          <el-button @click="delFunc()">删除</el-button>
          <el-button @click="viewInto()">查看</el-button>
          <el-button @click="trial()">试算</el-button>
          <el-button @click="viewCashFlow('0')">查看现金流</el-button>
        </template>
        <!-- 搜索区 -->
        <template slot="searchArea">
          <el-form
            :model="searchForm"
            ref="searchForm"
            label-width="60px"
            label-position="left"
            size="mini"
          >
            <el-form-item label="账号：">
              <el-input
                v-model="searchForm.acctNo"
                style="width:150px"
              ></el-input>
            </el-form-item>
            <el-form-item label="机构：" prop="orgCd">
              <auto-form
                v-model="searchForm.orgCd"
                elementType="6"
                dimCode="cpm_dim_organ"
                style="width:150px"
              ></auto-form>
            </el-form-item>
            <el-form-item label="科目：" prop="sbjtCd">
              <auto-form
                v-model="searchForm.sbjtCd"
                elementType="6"
                dimCode="cpm_dim_subject"
                style="width:150px"
              ></auto-form>
            </el-form-item>
            <el-form-item label="币种：" prop="ccyCd">
              <el-select v-model="searchForm.ccyCd" style="width:150px">
                <el-option
                  v-for="item in currencyList"
                  :key="item.ccyCd"
                  :value="item.currencyCode"
                  :label="item.currencyName"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="情景：" prop="sceneCode">
              <el-select v-model="searchForm.sceneCode" style="width:150px">
                <el-option
                  v-for="item in sceneList"
                  :key="item.ccyCd"
                  :value="item.sceneCode"
                  :label="item.sceneName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </template>
        <!-- 显示隐藏区 -->
        <template slot="columnHide">
          <el-checkbox-group v-model="checkList">
            <el-checkbox
              v-for="item in textData"
              :label="item.label"
              :key="item.prop"
              >{{ item.label }}
            </el-checkbox>
          </el-checkbox-group>
        </template>
      </upper-template>

      <el-table
        :header-cell-style="{ 'white-space': 'nowrap', width: 'auto' }"
        ref="multipleTable"
        :data="tableData"
        @row-click="rowChecked"
      >
        <el-table-column
          width="55"
          type="selection"
          
        ></el-table-column>
        <el-table-column
          prop="acctNo"
          label="账号"
          v-if="columnState[0]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="dataDt"
          label="数据日期"
          v-if="columnState[1]"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <div v-if="scope.row.dataDt">
              {{ timeFormat(scope.row.dataDt) }}
            </div>
            <div v-else>-</div>
          </template>
        </el-table-column>
        <el-table-column prop="orgCd" label="机构" v-if="columnState[2]">
        </el-table-column>
        <el-table-column prop="industryCd" label="行业" v-if="columnState[3]">
        </el-table-column>
        <el-table-column prop="custNo" label="客户编号" v-if="columnState[4]">
        </el-table-column>
        <el-table-column
          prop="prdCd"
          label="产品"
          v-if="columnState[5]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column prop="sbjtCd" label="科目" v-if="columnState[6]">
        </el-table-column>
        <el-table-column
          prop="sbjtTp"
          label="业务类型"
          v-if="columnState[7]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="ccyCd"
          label="币种"
          v-if="columnState[8]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="matuFlg"
          label="有无到期日标识"
          v-if="columnState[9]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="curBal"
          label="当前余额"
          v-if="columnState[10]"
          show-overflow-tooltip
          :formatter="row => (row.curBal ? (row.curBal * 1).toFixed(6) : '')"
        >
        </el-table-column>
        <el-table-column
          prop="origAmt"
          label="原始余额"
          :formatter="row => (row.origAmt ? (row.origAmt * 1).toFixed(6) : '')"
          v-if="columnState[11]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="lastRepricBal"
          label="上次重定价余额"
          :formatter="
            row => (row.lastRepricBal ? (row.lastRepricBal * 1).toFixed(6) : '')
          "
          v-if="columnState[12]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="pmtBal"
          label="支付金额"
          :formatter="row => (row.pmtBal ? (row.pmtBal * 1).toFixed(6) : '')"
          v-if="columnState[13]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="startDt"
          label="起息日"
          v-if="columnState[14]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="matuDt"
          label="到期日"
          v-if="columnState[15]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="term"
          label="原始期限"
          v-if="columnState[16]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="odueTerm"
          label="逾期期限"
          v-if="columnState[17]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="execRate"
          label="对客利率"
          v-if="columnState[18]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="acruIntstBas"
          label="计息基础代码"
          v-if="columnState[19]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="execRateCd"
          label="利率代码"
          v-if="columnState[20]"
          show-overflow-tooltip
        >
        </el-table-column>

        <el-table-column
          prop="fltTpCd"
          label="浮动类型代码"
          v-if="columnState[21]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="fltRatio"
          label="浮动比例"
          v-if="columnState[22]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="fltMargin"
          label="浮动利差"
          v-if="columnState[23]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="lastExecRateChangeDt"
          label="最新执行利率变更日期"
          v-if="columnState[24]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="intstPmtFreq"
          label="结息频率"
          v-if="columnState[25]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="rateTp"
          label="利率类型代码"
          v-if="columnState[26]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="rpricDtAdjstTp"
          label="重定价类型代码"
          v-if="columnState[27]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="lastRpricDt"
          label="上次重定价日期"
          v-if="columnState[28]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="nextRepricDt"
          label="下次重定价日期"
          v-if="columnState[29]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="repricFreq"
          label="重定价频率"
          v-if="columnState[30]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="pmtTp"
          label="支付类型代码"
          v-if="columnState[33]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="lastPrinPmtDt"
          label="上次支付日"
          v-if="columnState[34]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="nextPrinPmtDt"
          label="下次支付日"
          v-if="columnState[35]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="prinPmtFreq"
          label="支付频率"
          v-if="columnState[36]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="bizRatingCd"
          label="业务评级代码"
          v-if="columnState[37]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="custCateCd"
          label="客户类别代码"
          v-if="columnState[38]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="chnlNm"
          label="渠道"
          v-if="columnState[39]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="bizNo"
          label="业务编号"
          v-if="columnState[40]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="isOdue"
          label="逾期标识"
          v-if="columnState[41]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="earlyPmtAmt"
          label="提前还款金额"
          v-if="columnState[42]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="issuerCd"
          label="发行人代码"
          v-if="columnState[43]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="rateSensitiveFlg"
          label="利率敏感标识"
          v-if="columnState[44]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="instrumentTpCd"
          label="金融工具类型代码"
          v-if="columnState[45]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="costCtrTpCd"
          label="成本中心分类代码"
          v-if="columnState[46]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="isSbjtOdue"
          label="资产负债逾期标识"
          v-if="columnState[47]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="offshoreFlg"
          label="离岸标识"
          v-if="columnState[48]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="sizeFlg"
          label="规模标识"
          v-if="columnState[49]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="isAgmt"
          label="协定标识"
          v-if="columnState[50]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="pmtPlanFlg"
          label="还款计划表标识"
          v-if="columnState[51]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="incrementFlg"
          label="增量标识"
          v-if="columnState[52]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="lastRpricExecRate"
          label="上次重定价执行利率"
          v-if="columnState[53]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="nextmtAmt"
          label="下次支付金额"
          v-if="columnState[54]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="firstPrinPmtDt"
          label="首次还款日"
          v-if="columnState[55]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="billRate"
          label="票面利率"
          v-if="columnState[56]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="isVlid"
          label="数据有效性标识"
          v-if="columnState[57]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="bizLineCd"
          label="条线"
          v-if="columnState[58]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="area"
          label="区域"
          v-if="columnState[59]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="outIntstIncExp"
          label="外部利息收支"
          v-if="columnState[60]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append1"
          label="备用字段1"
          v-if="columnState[61]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append2"
          label="备用字段2"
          v-if="columnState[62]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append3"
          label="备用字段3"
          v-if="columnState[63]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append4"
          label="备用字段4"
          v-if="columnState[64]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append5"
          label="备用字段5"
          v-if="columnState[65]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append6"
          label="备用字段6"
          v-if="columnState[66]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append7"
          label="备用字段7"
          v-if="columnState[67]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append8"
          label="备用字段8"
          v-if="columnState[68]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append9"
          label="备用字段9"
          v-if="columnState[69]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append10"
          label="备用字段10"
          v-if="columnState[70]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append11"
          label="备用字段11"
          v-if="columnState[71]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append12"
          label="备用字段12"
          v-if="columnState[72]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append13"
          label="备用字段13"
          v-if="columnState[73]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append14"
          label="备用字段14"
          v-if="columnState[74]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append15"
          label="备用字段15"
          v-if="columnState[75]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append16"
          label="备用字段16"
          v-if="columnState[76]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append17"
          label="备用字段17"
          v-if="columnState[77]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append18"
          label="备用字段18"
          v-if="columnState[78]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append19"
          label="备用字段19"
          v-if="columnState[79]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="append20"
          label="备用字段20"
          v-if="columnState[79]"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="dataSrc"
          label="数据来源"
          v-if="columnState[79]"
          show-overflow-tooltip
        >
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchForm.page"
        :page-size="searchForm.size"
        @refresh="searchFunc"
        :total="total"
      ></pagination>
    </el-row>

    <el-dialog
      v-dialogDrag
      :title="saveTitles[saveFlg - 1]"
      :visible.sync="addOrEdit"
      width="514px"
    >
      <el-form
        :model="saveForm"
        ref="saveForm"
        :disabled="saveFlg == 3"
        label-width="130px"
        label-position="left"
        :rules="saveFormRules"
        :validate-on-rule-change="false"
      >
        <span class="formTitle"><i class="vertical-bar"></i>情景规则</span>
        <el-form-item label="情景：" prop="sceneCode">
          <el-select
            v-model="saveForm.sceneCode"
            clearable
            :disabled="saveForm.pricMethId != ''"
            style="width: 100%"
            @change="sceneCodeChange"
          >
            <el-option
              v-for="item in sceneList"
              :key="item.ccyCd"
              :value="item.sceneCode"
              :label="item.sceneName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="定价曲线：" prop="rateCurveCd">
          <el-select
            v-model="saveForm.rateCurveCd"
            style="width: 100%"
            clearable
            :disabled="saveForm.sceneCode != ''"
          >
            <el-option
              v-for="item in rateCurveList"
              :key="item.rateCurveCd"
              :value="item.curveCode"
              :label="item.curveName"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="调整项：">
          <el-cascader
            :disabled="saveForm.sceneCode != ''"
            clearable
            filterable
            :options="adjRuleGroupList"
            v-model="saveForm.adjRuleGroup"
            placeholder="请选择"
            :show-all-leaves="false"
            :props="{
              checkStrictly: true,
              emitPath: false,
              multiple: true,
              value: 'adjRuleGroup',
              label: 'ruleGroupName'
            }"
            style="width: 100%"
            ref="adjTree"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="定价方法：" prop="pricMethId">
          <el-select
            v-model="saveForm.pricMethId"
            clearable
            @change="pricMethIdChange"
            style="width: 100%"
            :disabled="saveForm.sceneCode != ''"
          >
            <el-option
              v-for="item in pricMethList"
              :key="item.value"
              :value="item.value"
              :label="item.label"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- 1 :指定利率法start -->
        <template v-if="saveForm.pricMethId == '1'">
          <el-form-item label="指定类型：" prop="assignType">
            <el-select
              v-model="saveForm.assignType"
              style="width: 100%"
              @change="assignTypeChange"
            >
              <el-option
                v-for="item in assignTypeList"
                :key="item.value"
                :value="item.value"
                :label="item.label"
              ></el-option>
            </el-select>
          </el-form-item>
          <!-- 1.2 :指定利率值start -->
          <template v-if="saveForm.assignType == '1'">
            <el-form-item label="指定利率值(%)：" prop="assignRate">
              <el-input
                v-model="saveForm.assignRate"
                placeholder="请输入..."
              ></el-input>
            </el-form-item>
          </template>
          <!-- 1.2 :指定利率值end -->
          <!-- 1.2 :指定期限start -->
          <template v-if="saveForm.assignType == '2'">
            <el-form-item label="指定期限：" prop="assignTerm">
              <el-form-item
                prop="assignTerm"
                style="display: inline-block;width: 100px;"
              >
                <el-input v-model="saveForm.assignTerm"></el-input>
              </el-form-item>
              <el-form-item
                prop="assignTermMult"
                style="display: inline-block;width: 100px;"
              >
                <el-select v-model="saveForm.assignTermMult" style="width:100%">
                  <el-option
                    v-for="item in termList"
                    :key="item.value"
                    :value="item.value"
                    :label="item.label"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-form-item>
            <el-form-item label="跟踪日期类型：" prop="trackDateType">
              <el-select v-model="saveForm.trackDateType" style="width: 100%">
                <el-option
                  v-for="item in trackDateTypeList"
                  :key="item.value"
                  :value="item.value"
                  :label="item.label"
                ></el-option>
              </el-select>
            </el-form-item>
          </template>
          <!-- 1.2 :指定期限end -->
        </template>
        <!-- 1 :指定利率法end -->
        <!-- 2 :期限匹配法 start-->
        <!-- 无 -->
        <!-- 2 :期限匹配法 end -->
        <!-- 3 :现金流法 start-->
        <template v-if="saveForm.pricMethId == '3'">
          <el-form-item label="是否含息：" prop="interestFlag">
            <el-select v-model="saveForm.interestFlag" style="width: 100%">
              <el-option
                v-for="item in isOrNoList"
                :key="item.value"
                :value="item.value"
                :label="item.label"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否折现：" prop="discountFlag">
            <el-select v-model="saveForm.discountFlag" style="width: 100%">
              <el-option
                v-for="item in isOrNoList"
                :key="item.value"
                :value="item.value"
                :label="item.label"
              ></el-option>
            </el-select>
          </el-form-item>
        </template>
        <!-- 3 :现金流法 end-->
        <!-- 4 : 利率差额法start -->
        <template v-if="saveForm.pricMethId == '4'">
          <el-form-item label="利差值：" prop="intDiff">
            <el-input
              v-model="saveForm.intDiff"
              placeholder="请输入..."
              maxlength="40"
            ></el-input>
          </el-form-item>
        </template>
        <!-- 4 :利率差额法end -->
        <!-- 5 : 移动平均法start -->
        <template v-if="saveForm.pricMethId == '5'">
          <el-form-item label="指定期限：" prop="assignTerm">
            <el-form-item
              prop="assignTerm"
              style="display: inline-block;width: 100px;"
            >
              <el-input v-model="saveForm.assignTerm"></el-input>
            </el-form-item>
            <el-form-item
              prop="assignTermMult"
              style="display: inline-block;width: 100px;"
            >
              <el-select v-model="saveForm.assignTermMult" style="width:100%">
                <el-option
                  v-for="item in termList"
                  :key="item.value"
                  :value="item.value"
                  :label="item.label"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
          <el-form-item label="移动平均期限：" prop="averagePeriod">
            <el-form-item
              prop="averagePeriod"
              style="display: inline-block;width: 100px;"
            >
              <el-input v-model="saveForm.averagePeriod"></el-input>
            </el-form-item>
            <el-form-item
              prop="averagePeriodMult"
              style="display: inline-block;width: 100px;"
            >
              <el-select
                v-model="saveForm.averagePeriodMult"
                style="width:100%"
              >
                <el-option
                  v-for="item in termList"
                  :key="item.value"
                  :value="item.value"
                  :label="item.label"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form-item>
        </template>
        <!-- 5 :移动平均法end -->
        <!-- 6 :偿还曲线法start -->
        <template v-if="saveForm.pricMethId == '6'">
          <el-form-item prop="testRepayCurveMethods" label="余额占比：">
            <repay-curve-list
              :data="saveForm.testRepayCurveMethods"
            ></repay-curve-list>
          </el-form-item>
        </template>
        <!-- 6 :偿还曲线法end -->
        <!-- 7 :久期法 start-->
        <template v-if="saveForm.pricMethId == '7'">
          <el-form-item label="期限类型：" prop="termType">
            <el-select v-model="saveForm.termType" style="width: 100%">
              <el-option value="1" label="原始期限"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="折现率类型：" prop="discountType">
            <el-select
              v-model="saveForm.discountType"
              @change="saveForm.discountCurveId = ''"
              style="width: 100%"
            >
              <el-option
                v-for="item in discountTypeList"
                :key="item.value"
                :value="item.value"
                :label="item.label"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="折现曲线："
            prop="discountCurveId"
            v-if="saveForm.discountType == '2'"
          >
            <el-select v-model="saveForm.discountCurveId" style="width: 100%">
              <el-option
                v-for="item in rateCurveList"
                :key="item.rateCurveCd"
                :value="item.curveCode"
                :label="item.curveName"
              ></el-option>
            </el-select>
          </el-form-item>
        </template>
        <!-- 7 :久期法 end-->
        <!-- 8 :结构化 start-->
        <!--暂无-->
        <!-- 8 :结构化 end-->
        <div v-for="(configClass, index) in testConfigDtoMap" :key="index">
          <span class="formTitle"
            ><i class="vertical-bar"></i>{{ fieldClassifyMap[index + 1] }}</span
          >
          <el-form-item
            v-for="configItem in configClass"
            :key="configItem.testConfig.elementField"
            :label="configItem.businessEle.elementName + '：'"
            :prop="
              configItem.businessEle.elementType != '5'
                ? configItem.testConfig.elementField
                : ''
            "
          >
            <!-- 普通元素类型 1 2 3 4 6 -->
            <auto-form
              v-model="saveForm[configItem.testConfig.elementField]"
              :elementType="configItem.businessEle.elementType"
              :dimCode="configItem.businessEle.dimensionCode"
              :disabled="getDisabled(configItem.testConfig.elementField)"
            ></auto-form>
            <!-- 期限类型组合 -->
            <template v-if="configItem.businessEle.elementType == '5'">
              <el-form-item
                :prop="configItem.businessEle.elementField"
                style="display: inline-block;width: 100px;"
              >
                <el-input
                  v-model="saveForm[configItem.businessEle.elementField]"
                  :disabled="getDisabled(configItem.businessEle.elementField)"
                ></el-input>
              </el-form-item>
              <el-form-item
                :prop="configItem.businessEle.elementField + 'Mult'"
                style="display: inline-block;width: 100px;"
              >
                <el-select
                  v-model="
                    saveForm[configItem.businessEle.elementField + 'Mult']
                  "
                  :disabled="
                    getDisabled(configItem.businessEle.elementField + 'Mult')
                  "
                  style="width:100%"
                >
                  <el-option
                    v-for="item in termList"
                    :key="item.value"
                    :value="item.value"
                    :label="item.label"
                  ></el-option>
                </el-select>
              </el-form-item>
            </template>
          </el-form-item>
        </div>
      </el-form>
      <el-dialog
        title="支付计划表"
        v-dialogDrag
        :visible.sync="isPlanShow"
        width="800px"
        append-to-body
      >
        <plan-window
          :acctNo="saveForm.acctNo"
          :isPlanShow="isPlanShow"
        ></plan-window>
        <!-- <div slot="footer"></div> -->
      </el-dialog>

      <div slot="footer" class="dialog-footer">
        <el-button
          :disabled="this.saveForm.pmtTp != 'G'"
          v-if="saveFlg != 3"
          @click="isPlanShow = true"
          >编辑还款计划</el-button
        >
        <el-button @click="saveFunc" v-if="saveFlg != 3">保 存</el-button>
        <el-button @click="addOrEdit = false" v-if="saveFlg != 3"
          >取 消</el-button
        >
        <el-button @click="addOrEdit = false" v-if="saveFlg == 3"
          >关 闭</el-button
        >
      </div>
    </el-dialog>
    <!-- 查看现金流 -->
    <el-dialog title="查看现金流" v-dialogDrag :visible.sync="showCashFlow">
      <cash-flow :param="cashFlowParam" :flag="showCashFlow"></cash-flow>
      <div slot="footer">
        <el-button @click="showCashFlow = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { publicManage_pub, pricingTrial } from "@/api/index";
import { getDict } from "@/api/getDict";
import autoForm from "@/components/ftp/autoForm.vue";
import moment from "moment";
import planWindow from "../onlineConfiger/com/planTbaleCom";
import cashFlow from "./com/testCashFlow";
import repayCurveList from "./com/repayCurveList";
export default {
  data() {
    return {
      addOrEdit: false, // 新增/编辑/查看弹窗
      isPlanShow: false, // 计划表窗口
      saveFlg: 1, // 1:新增，2：编辑，3查看,
      saveTitles: ["新增模拟定价数据", "编辑模拟定价数据"],
      // 币种list
      currencyList: [],
      // 情景list
      sceneList: [],
      // 曲线list
      rateCurveList: [],
      // 调整项树
      adjRuleGroupList: [],
      // 定价方法
      pricMethList: [],
      // 指定类型
      assignTypeList: [],
      // 跟踪日期类型
      trackDateTypeList: [],
      // 折现率类型
      discountTypeList: [],
      // 是否
      isOrNoList: [
        { value: "1", label: "是" },
        { value: "0", label: "否" }
      ],
      searchForm: {
        acctNo: "",
        orgCd: "",
        sbjtCd: "",
        ccyCd: "",
        sceneCode: "",
        page: 1,
        size: 15
      },
      total: 100,
      saveForm: {
        sceneCode: "",
        rateCurveCd: "",
        adjRuleGroup: [],
        pricMethId: "",
        assignType: "",
        assignRate: "",
        assignTerm: "",
        assignTermMult: "",
        trackDateType: "",
        interestFlag: "",
        discountFlag: "",
        intDiff: "",
        averagePeriod: "",
        averagePeriodMult: "",
        testRepayCurveMethods: [],
        termType: "",
        discountType: "",
        discountCurveId: "",
        acctNo: "",
        dataDt: "",
        orgCd: "",
        industryCd: "",
        custNo: "",
        prdCd: "",
        sbjtCd: "",
        sbjtTp: "",
        ccyCd: "",
        matuFlg: "",
        curBal: "",
        origAmt: "",
        lastRepricBal: "",
        pmtBal: "",
        startDt: "",
        matuDt: "",
        term: "",
        termMult: "",
        odueTerm: "",
        odueTermMult: "",
        execRate: "",
        acruIntstBas: "",
        execRateCd: "",
        fltTpCd: "",
        fltRatio: "",
        fltMargin: "",
        lastExecRateChangeDt: "",
        intstPmtFreq: "",
        intstPmtFreqMult: "",
        rateTp: "",
        rpricDtAdjstTp: "",
        lastRpricDt: "",
        nextRepricDt: "",
        repricFreq: "",
        repricFreqMult: "",
        pmtTp: "",
        lastPrinPmtDt: "",
        nextPrinPmtDt: "",
        prinPmtFreq: "",
        prinPmtFreqMult: "",
        bizRatingCd: "",
        custCateCd: "",
        chnlNm: "",
        bizNo: "",
        isOdue: "",
        earlyPmtAmt: "",
        issuerCd: "",
        rateSensitiveFlg: "",
        instrumentTpCd: "",
        costCtrTpCd: "",
        isSbjtOdue: "",
        offshoreFlg: "",
        sizeFlg: "",
        isAgmt: "",
        pmtPlanFlg: "",
        incrementFlg: "",
        lastRpricExecRate: "",
        nextmtAmt: "",
        firstPrinPmtDt: "",
        billRate: "",
        isVlid: "",
        bizLineCd: "",
        area: "",
        outIntstIncExp: "",
        append1: "",
        append2: "",
        append3: "",
        append4: "",
        append5: "",
        append6: "",
        append7: "",
        append8: "",
        append9: "",
        append10: "",
        append11: "",
        append12: "",
        append13: "",
        append14: "",
        append15: "",
        append16: "",
        append17: "",
        append18: "",
        append19: "",
        append20: "",
        dataSrc: ""
      },
      saveFormRules: {},
      checkList: [],
      // 列隐藏
      textData: [
        { label: "账号" },
        { label: "数据日期 " },
        { label: "机构" },
        { label: "行业" },
        { label: "客户编号 " },
        { label: "产品" },
        { label: "科目" },
        { label: "业务类型" },
        { label: "币种" },
        { label: "有无到期日标志" },
        { label: "当前余额" },
        { label: "原始余额" },
        { label: "上次重定价余额" },
        { label: "支付金额" },
        { label: "起息日" },
        { label: "到期日" },
        { label: "原始期限" },
        { label: "逾期期限" },
        { label: "对客利率" },
        { label: "计息基础代码" },
        { label: "利率代码" },
        { label: "浮动类型代码" },
        { label: "浮动比例" },
        { label: "浮动利差" },
        { label: "最新执行利率变更日期" },
        { label: "结息频率" },
        { label: "利率类型代码" },
        { label: "重定价类型代码" },
        { label: "上次重定价日期" },
        { label: "下次重定价日期" },
        { label: "重定价频率" },
        { label: "支付类型代码" },
        { label: "上次支付日" },
        { label: "下次支付日" },
        { label: "支付频率" },
        { label: "业务评级代码" },
        { label: "客户类别代码" },
        { label: "渠道" },
        { label: "业务编号" },
        { label: "逾期标识" },
        { label: "提前还款金额" },
        { label: "发行人代码" },
        { label: "利率敏感标识" },
        { label: "金融工具类型代码" },
        { label: "成本中心分类代码" },
        { label: "资产负债逾期标识" },
        { label: "离岸标识" },
        { label: "规模标识" },
        { label: "协定标识" },
        { label: "还款计划表标识" },
        { label: "增量标识" },
        { label: "上次重定价执行利率" },
        { label: "下次支付金额" },
        { label: "首次还款日" },
        { label: "票面利率" },
        { label: "数据有效性标识" },
        { label: "条线" },
        { label: "区域" },
        { label: "外部利息收支" },
        { label: "备用字段1" },
        { label: "备用字段2" },
        { label: "备用字段3" },
        { label: "备用字段4" },
        { label: "备用字段5" },
        { label: "备用字段6" },
        { label: "备用字段7" },
        { label: "备用字段8" },
        { label: "备用字段9" },
        { label: "备用字段10" },
        { label: "备用字段11" },
        { label: "备用字段12" },
        { label: "备用字段13" },
        { label: "备用字段14" },
        { label: "备用字段15" },
        { label: "备用字段16" },
        { label: "备用字段17" },
        { label: "备用字段18" },
        { label: "备用字段19" },
        { label: "备用字段20" },
        { label: "数据来源" }
      ],
      // 获取table的数据
      tableData: [],
      // 是否显示现金流弹窗
      showCashFlow: false,
      cashFlowParam: {}, // 传入现金流组件的参数
      //编辑行内数据暂存，供判断表单状态
      editRow: {},
      // 表单title分类
      fieldClassifyMap: {
        "1": "基础信息",
        "2": "利率信息",
        "3": "期限信息",
        "4": "支付信息",
        "5": "重定价信息",
        "6": "其他信息",
        "7": "备用字段"
      },
      // toForm表单详情,供遍历
      testConfigDtoMap: [],
      // //期限下拉
      termList: [
        { value: "Y", label: "年" },
        { value: "M", label: "月" },
        { value: "D", label: "日" }
      ],
      // 校验错误信息提示
      errMessage: ""
      // // 业务类型下拉
      // sbjtTpList: [],
      // // 计息基础下拉
      // acruIntstBasList: [],
      // // 支付类型下拉
      // pmtTpList: [],
      // // 还款计划标识下拉
      // pmtPlanFlgList: [],
      // // 利率类型
      // rateTpList: [],
      // // 重定价类型下拉
      // rpricDtAdjstTpList: [],
      // // 业务评级下拉
      // bizRatingList: [],
      // // 渠道
      // chnlNmList: [],
      // // 逾期标识下拉
      // isOdueList: [],
      // // 资产负债逾期标识下拉
      // isSbjtOdueList: [],
      // // 金融工具类型下拉
      // instrumentTpList: [],
      // // 规模标识
      // sizeFlgList: [],
      // // 增量标识下拉
      // incrementFlgList: [],
      // // 来源系统
      // dataSrcList: [],
      // //客户类别
      // custCateList: [],
      // // 发行人
      // issuerList: [],
      // // 成本中心分类
      // costCtrTpList: [],
      // // 离岸标识
      // offshoreFlgList: [],
      // // 协定标识
      // isAgmtList: [],
      // // 数据有效性标识下拉
      // isVlidList: []
    };
  },
  components: {
    "auto-form": autoForm,
    "plan-window": planWindow,
    "cash-flow": cashFlow,
    "repay-curve-list": repayCurveList
  },
  created() {
    this.checkListInit();
    this.searchFunc();
    this.getDict();
    this.getCcyList();
  },
  computed: {
    columnState() {
      let arr = [],
        arr1 = this.textData,
        arr2 = this.checkList;
      for (let i = 0; i < arr1.length; i++) {
        let flg = false;
        for (let j = 0; j < arr2.length; j++) {
          if (arr1[i].label === arr2[j]) {
            flg = true;
          }
        }
        arr.push(flg);
      }
      return arr;
    }
  },
  mounted() {},
  watch: {
    addOrEdit() {
      // 窗口打开或关闭清除校验结果
      if (this.$refs.saveForm) {
        this.$refs.saveForm.clearValidate();
      }
    },
    "saveForm.rateTp"(n, o) {
      if (n != "A") {
        this.saveForm.rpricDtAdjstTp = "";
        this.saveForm.repricFreq = "";
        this.saveForm.repricFreqMult = "";
        this.saveForm.lastRpricDt = "";
        this.saveForm.nextRepricDt = "";
      }
      if (n == "A") {
        this.saveForm.lastRpricDt = moment(new Date()).format("YYYY-MM-DD");
      }
    },
    "saveForm.pmtTp"(n, o) {
      if (n == "A") {
        this.saveForm.prinPmtFreq = "";
        this.saveForm.prinPmtFreqMult = "";
        this.saveForm.nextPrinPmtDt = "";
      }
    }
  },
  methods: {
    clearSearch() {
      for (const key in this.searchForm) {
        this.searchForm[key] = "";
      }
      this.searchForm.page = 1;
      this.searchForm.size = 15;
    },
    // 获取所有字段的配置
    toForm() {
      let data = {
        acctNo: this.saveForm.acctNo,
        operateType: this.saveFlg
      };
      pricingTrial.pricingTestToForm(data).then(res => {
        if (res.code == 200) {
          this.fieldClassifyMap = res.data.fieldClassifyMap;
          this.testConfigDtoMap = Object.values(res.data.testConfigDtoMap);
          // 表单查出的字段是翻译过的，这里toform返回了所有原始字段录入的信息，拿这个用来填充saveForm
          let form = { ...res.data.pricingTest };
          for (const key in form) {
            if (typeof form[key] == "number") {
              form[key] += "";
            }
          }
          this.editRow = form;
          for (const key in this.saveForm) {
            this.saveForm[key] = form[key];
          }
          this.rulesUpdate();
          this.addOrEdit = true;
          console.log(this.saveForm);
        }
      });
    },
    // 校验规则更新
    rulesUpdate() {
      let rules = {
        // 情景与规则字段
        assignType: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        assignRate: [
          { required: true, message: "请输入必填项", trigger: "blur" },
          {
            pattern: /(^[0-9]{1,2}$)|(^[0-9]{1,2}[\.]{1}[0-9]{1,6}$)/,
            message: "只能输入整数小于2位，小数小于6位的数字",
            trigger: "blur"
          }
        ],
        assignTerm: [
          { required: true, message: "请输入必填项", trigger: "blur" },
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          }
        ],
        assignTermMult: [
          { required: true, message: "补全单位", trigger: "blur" }
        ],
        trackDateType: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        interestFlag: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        discountFlag: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        intDiff: [
          { required: true, message: "请输入必填项", trigger: "blur" },
          {
            pattern: /(^[0-9]{1,6}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,6}$)/,
            message: "只能输入整数小于6位，小数小于6位的数字",
            trigger: "blur"
          }
        ],
        averagePeriod: [
          { required: true, message: "请输入必填项", trigger: "blur" },
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          }
        ],
        averagePeriodMult: [
          { required: true, message: "补全单位", trigger: "blur" }
        ],
        testRepayCurveMethods: [
          { required: true, message: "请新增余额占比", trigger: "blur" }
        ],
        termType: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        discountType: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        discountCurveId: [
          { required: true, message: "请输入必填项", trigger: "blur" }
        ],
        // 其他动态字段
        acctNo: [
          {
            pattern: /^[A-Z_0-9]{3,40}$/,
            message: "只能输入3-40位的大写英文字母或数字",
            trigger: "blur"
          }
          // { validator: this.acctNoValid, trigger: "blur" }
        ],
        custNo: [
          {
            pattern: /^[\u4E00-\u9FA5A-Za-z0-9_]{0,20}$/,
            message: "只能输入0-20位英文字母、数字、汉字、下划线",
            trigger: "blur"
          }
        ],
        origAmt: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        curBal: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        pmtBal: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        nextmtAmt: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        earlyPmtAmt: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        lastRpricExecRate: [
          {
            pattern: /(^[0-9]{1,6}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,6}$)/,
            message: "只能输入整数小于6位，小数小于6位的数字",
            trigger: "blur"
          }
        ],
        execRate: [
          {
            pattern: /(^[0-9]{1,6}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,6}$)/,
            message: "只能输入整数小于6位，小数小于6位的数字",
            trigger: "blur"
          }
        ],
        fltMargin: [
          {
            pattern: /(^[0-9]{1,6}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,6}$)/,
            message: "只能输入整数小于6位，小数小于6位的数字",
            trigger: "blur"
          }
        ],
        billRate: [
          {
            pattern: /(^[0-9]{1,6}$)|(^[0-9]{1,6}[\.]{1}[0-9]{1,6}$)/,
            message: "只能输入整数小于6位，小数小于6位的数字",
            trigger: "blur"
          }
        ],
        lastRepricBal: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        outIntstIncExp: [
          {
            pattern: /(^[0-9]{1,18}$)|(^[0-9]{1,18}[\.]{1}[0-9]{1,4}$)/,
            message: "只能输入整数小于18位，小数小于4位的数字",
            trigger: "blur"
          }
        ],
        bizNo: [
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          }
        ],
        intstPmtFreq: [
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          }
        ],
        intstPmtFreqMult: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.intstPmtFreq && value == "") {
                callback(new Error("请填补全单位"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        term: [
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          }
        ],
        termMult: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.term && value == "") {
                callback(new Error("请填补全单位"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        odueTerm: [
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          }
        ],
        odueTermMult: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.odueTerm && value == "") {
                callback(new Error("请填补全单位"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        prinPmtFreq: [
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          },
          {
            validator: (rule, value, callback) => {
              if (
                this.saveForm.pmtTp &&
                this.saveForm.pmtTp != "A" && this.saveForm.pmtTp != "G" &&
                value == ""
              ) {
                this.errMessage =
                  "支付类型不是一次性还本付息或不是根据还款计划时 <strong>支付频率</strong>不能为空";
                callback(new Error("请填写支付频率"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        prinPmtFreqMult: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.prinPmtFreq && value == "") {
                callback(new Error("请填补全单位"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        rpricDtAdjstTp: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.rateTp == "A" && value == "") {
                this.errMessage =
                  "利率类型为浮动利率时 <strong>重定价类型</strong>不能为空";
                callback(new Error("利率类型为浮动利率时，重定价类型不能为空"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        repricFreq: [
          {
            pattern: /^[0-9]{0,9}$/,
            message: "只能输入小于9位正整数",
            trigger: "blur"
          },
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.rateTp == "A" && value == "") {
                this.errMessage =
                  "利率类型为浮动利率时 <strong>重定价频率</strong>不能为空";
                callback(new Error("利率类型为浮动利率时，重定价频率不能为空"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        repricFreqMult: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.repricFreq && value == "") {
                callback(new Error("请填补全单位"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        pmtTp: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.matuFlg == "1" && value == "") {
                this.errMessage = "有到期日时<strong>支付类型</strong>不能为空";
                callback(new Error("请填写支付类型"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        rateTp: [
          {
            validator: (rule, value, callback) => {
              if (this.saveForm.matuFlg == "1" && value == "") {
                this.errMessage = "有到期日时<strong>利率类型</strong>不能为空";
                callback(new Error("请填写利率类型"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ]
      };
      // 找必填的项加入校验规则前
      for (let key in this.testConfigDtoMap) {
        for (
          let index = 0;
          index < this.testConfigDtoMap[key].length;
          index++
        ) {
          const el = this.testConfigDtoMap[key][index];
          if (!rules[el.testConfig.elementField]) {
            rules[el.testConfig.elementField] = [];
          }
          if (el.testConfig.inputFlag == "1") {
            rules[el.testConfig.elementField].unshift({
              required: true,
              message: "请输入必填项",
              trigger: "blur"
            });
          }
        }
      }
      this.saveFormRules = rules;
      this.$forceUpdate();
    },
    // 初始化table显示隐藏状态
    checkListInit() {
      this.checkList = this.textData.map(v => {
        return v.label;
      });
    },
    // 获取可用币种
    getCcyList() {
      publicManage_pub
        .currencyManageQueryAvailable({ page: 1, size: 999 })
        .then(res => {
          this.currencyList = res.data;
        });
    },
    // 获取所有字典和下拉框
    getDict() {
      // 定价方法字典
      getDict("ftp_cp_ftp_method").then(res => {
        if (res.code == 200) {
          this.pricMethList = res.datas;
        }
      });
      // 指定类型字典
      getDict("ftp_assign_type").then(res => {
        if (res.code == 200) {
          this.assignTypeList = res.datas;
        }
      });
      // 跟踪日期类型字典
      getDict("ftp_cp_track_date_cd").then(res => {
        if (res.code == 200) {
          this.trackDateTypeList = res.datas;
        }
      });
      // 折现率类型
      getDict("ftp_discountType").then(res => {
        if (res.code == 200) {
          this.discountTypeList = res.datas;
        }
      });
      // 查询情景
      pricingTrial.sceneManageFindAll({ page: 1, size: 999 }).then(res => {
        if (res.code == 200) {
          this.sceneList = res.datas.rows;
        }
      });
      // 查询曲线
      publicManage_pub.baseCurveDefQuery({ page: 1, size: 999 }).then(res => {
        if (res.code == 200) {
          this.rateCurveList = res.data;
        }
      });
      // 查询调整项树
      pricingTrial.pricingTestAdjRuleGroupTree().then(res => {
        if (res.code == 200) {
          this.adjRuleGroupList = this.$listToTree(
            "adjRuleGroup",
            "parentAdjRuleGroup",
            res.datas
          );
        }
      });
    },
    // 查询
    searchFunc() {
      let data = this.searchForm;
      pricingTrial.pricingTestFindAll(data).then(res => {
        if (res.code == 200) {
          this.total = res.total;
          this.tableData = res.rows;
        }
        // this.tableData = res.data.sort((x, y) => {
      });
    },
    addFunc() {
      this.saveFlg = 1;
      for (let k in this.saveForm) {
        this.saveForm[k] = "";
      }
      this.toForm();
    },
    editFunc() {
      this.saveFlg = 2;
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据进行修改");
      }
      let row = selection[0];
      this.saveForm.acctNo = row.acctNo;
      this.toForm();
    },
    copyFunc() {
      this.saveFlg = 5;
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据进行复制");
      }
      let row = selection[0];
      this.saveForm.acctNo = row.acctNo;
      this.toForm();
    },
    // 编号是否重复校验
    acctNoValid(rule, value, callback) {
      // 只在新增时校验
      if (this.saveFlg != 1) {
        callback();
        return;
      }
      pricingTrial
        .pricingTestCheckUsing({ validateParam: "acctNo:" + value })
        .then(res => {
          if (res.success) {
            callback();
          } else {
            callback(new Error("编号已存在"));
          }
        });
    },
    saveFunc() {
      if (this.saveForm.sceneCode == "" && this.saveForm.pricMethId == "")
        return this.$message.warning("定价方法与情景必须选择一个！");
      // 清空上次校验错误信息
      this.errMessage = "";
      this.$refs["saveForm"].validate(valid => {
        if (valid) {
          let data = {
            pricingTest: this.saveForm,
            operateType: this.saveFlg
          };
          pricingTrial.pricingTestSave(data).then(res => {
            if (res.code == 200) {
              this.$message.success("保存成功");
              this.addOrEdit = false;
              this.searchFunc();
            } else {
              this.$message.error(res.message || "保存失败");
            }
          });
        } else {
          this.$message.warning({
            dangerouslyUseHTMLString: true,
            message:
              this.errMessage || "您有校验未通过，请检查，根据表单提示填写",
            duration: 4000
          });
        }
      });
    },
    delFunc() {
      let selection = this.$refs.multipleTable.selection;
      if (selection.length < 1) {
        return this.$message.warning("请选择要删除的数据");
      }
      this.$confirm("您确定要删除选中数据吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let data = { ids: selection.map(v => v.acctNo) };
          pricingTrial.pricingTestRemove(data).then(res => {
            if (res.code == 200) {
              this.$message.success("删除成功");
              this.searchFunc();
            } else {
              this.$message.error(res.message || "删除失败");
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    // 查看
    viewInto(data) {
      this.saveFlg = 3;
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据查看");
      }
      let row = selection[0];
      this.saveForm.acctNo = row.acctNo;
      this.toForm();
    },
    // 试算
    trial() {
      let selection = this.$refs.multipleTable.selection;
      if (selection.length < 1) {
        return this.$message.warning("请选择要试算的内容");
      }

      let data = { ids: selection.map(v => v.acctNo) };
      pricingTrial.pricingTestTest(data).then(res => {
        if (res.code == 200) {
          this.$message.success(res.message || "成功");
          this.searchFunc();
        } else {
          this.$message.error(res.message || "失败");
        }
      });
    },
    // 查看现金流
    viewCashFlow() {
      let selection = this.$refs.multipleTable.selection;
      if (selection.length != 1) {
        return this.$message.warning("请选择一条数据");
      }
      let row = selection[0];
      let data = {
        acctNo: row.acctNo
      };
      this.cashFlowParam = data;
      this.showCashFlow = true;
    },
    // 情景选择，清空情景与规则其余三项
    sceneCodeChange() {
      this.saveForm.rateCurveCd = "";
      this.saveForm.adjRuleGroup = [];
      this.saveForm.pricMethId = "";
    },
    // 定价方法选择，清空情景，和所有定价方法下输入内容
    pricMethIdChange() {
      this.saveForm.sceneCode = "";
      this.saveForm.assignType = "";
      this.saveForm.assignRate = "";
      this.saveForm.assignTerm = "";
      this.saveForm.assignTermMult = "";
      this.saveForm.trackDateType = "";
      this.saveForm.interestFlag = "";
      this.saveForm.discountFlag = "";
      this.saveForm.intDiff = "";
      this.saveForm.averagePeriod = "";
      this.saveForm.averagePeriodMult = "";
      this.saveForm.testRepayCurveMethods = [];
      this.saveForm.termType = "";
      this.saveForm.discountType = "";
      this.saveForm.discountCurveId = "";
    },
    //指定类型选择，清空指定期限和指定利率值
    assignTypeChange() {
      this.saveForm.assignTerm = "";
      this.saveForm.assignTermMult = "";
      this.saveForm.assignRate = "";
    },
    rowChecked(row) {
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection();
        this.$refs.multipleTable.toggleRowSelection(row, true);
      }
    },
    getDisabled(field) {
      if (field == "acctNo") return true;
      if (
        (field == "rpricDtAdjstTp" ||
          field == "repricFreq" ||
          field == "repricFreqMult" ||
          field == "lastRpricDt" ||
          field == "nextRepricDt") &&
        this.saveForm.rateTp != "A"
      )
        return true;
      if (
        (field == "nextPrinPmtDt" ||
          field == "prinPmtFreq" ||
          field == "prinPmtFreqMult") &&
        this.saveForm.pmtTp == "A"
      )
        return true;

      return false;
    },
    timeFormat(val) {
      if (val) return moment(val).format("YYYY-MM-DD HH:mm:ss");
      else return "";
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.searchForm.size = val;
      this.searchFunc();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.searchForm.page = val;
      this.searchFunc();
    }
  }
};
</script>

<style lang="scss" scoped>
.dialogSearchBox {
  header {
    text-align: center;
    span {
      margin: 0 20px;
    }
  }
}
// /deep/.el-table__header-wrapper thead tr th {
//   white-space: nowrap !important;
// }
.formTitle {
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin-bottom: 10px;
}
</style>